﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Collections.ObjectModel;

namespace Medianamik.Core
{
    public class WebSite : SystemNode<WebSite>
    {
        #region .ctors

        public WebSite()
        {

        }

        #endregion

        #region Properties

        #region ISystemNode Members

        public override Guid SystemNodeTypeID
        {
            get
            {
                return MedianamikTypes.WebSite;
            }
        }

        #endregion

        private string _cssFilePath;
        public string CSSFilePath
        {
            get {

                if(_cssFilePath == null)
                    _cssFilePath = DefaultInstance.Properties["EditorCSSFilePath"].GetValue<string>();
                
                return _cssFilePath; 
            }
        }

        private string _editorImageFilesPath;
        public string EditorImageFilesPath
        {
            get
            {
                return _editorImageFilesPath ?? (_editorImageFilesPath =
                    DefaultInstance.Properties["EditorImageFilesPath"].GetValue<string>());
            }
        }

        private string _editorDocumentFilesPath;
        public string EditorDocumentFilesPath
        {
            get
            {
                return _editorDocumentFilesPath ?? (_editorDocumentFilesPath =
                    DefaultInstance.Properties["EditorDocumentFilesPath"].GetValue<string>());
            }
        }

        private string _rootFilesPath;
        public string RootFilesPath
        {
            get
            {
                return _rootFilesPath ?? (_rootFilesPath =
                    DefaultInstance.Properties["RootFilesPath"].GetValue<string>());
            }
        }

        private string _editorFlashFilesPath;
        public string EditorFlashFilesPath
        {
            get
            {
                return _editorFlashFilesPath ?? (_editorFlashFilesPath =
                    DefaultInstance.Properties["EditorFlashFilesPath"].GetValue<string>());
            }
        }

        private string _editorMediaFilesPath;
        public string EditorMediaFilesPath
        {
            get
            {
                return _editorMediaFilesPath ?? (_editorMediaFilesPath =
                    DefaultInstance.Properties["EditorMediaFilesPath"].GetValue<string>());
            }
        }

        public virtual string Prefix
        {
            get
            {

                var prefix = DefaultInstance.Properties["Prefix"].GetValue<string>();

                if (String.IsNullOrEmpty(prefix))
                    return "";

                return "/" + prefix.ToLowerInvariant().TrimStart('/').TrimEnd('/');
            }
        }     

        private Guid? _defaultDocumentId;
        public Guid? DefaultDocumentId
        {
            get
            {
                return _defaultDocumentId
                    ?? (_defaultDocumentId = DefaultInstance["DefaultDocument"].GetValue<Guid?>());
            }
        }


        #endregion

        #region Methods

        #endregion
    }
}
